CC_PRE=arm-none-eabi-
PLATFORM=$(platform)
SRCS =$(wildcard src/*.c)
OBJS =$(patsubst %.c,%.o,$(SRCS))
CFLAG= -c -mcpu=cortex-m3 -mthumb -O3 -D STM32F10X_HD -D USE_STDPERIPH_DRIVER -Istm32sdk/inc -Iinc
LDFLAG= -mcpu=cortex-m3 -mthumb -O3 -Lstm32sdk -nostartfiles -Tstm32sdk/stm32_flash.ld -Wl,--whole-archive app.a -Wl,--no-whole-archive -lm -lstm32f103zet6
.PHONY:mv
cp:main.hex
	@printf "Copy To VMPlayer\n"
	@cp main.hex ~/Software/vmware/shared
main.hex:main.elf
	@printf "\nPrintf Size %s\n" $^
	@$(CC_PRE)size $^
	@$(CC_PRE)objcopy -O ihex main.elf main.hex
	@printf "\n"
main.elf:app.a
	@printf "%-32s\033[35m==>\033[0m\t%-32s\n" $^ $@
	@$(CC_PRE)gcc $(LDFLAG) -o $@
app.a:$(OBJS)
	@printf "%-32s\033[32m==>\033[0m\t%-32s\n" [OBJS] $@
	@$(CC_PRE)ar cr $@ $^
%.o:%.c
	@printf "%-32s\033[34m==>\033[0m\t%-32s\n" $^ $@
	@$(CC_PRE)gcc $(CFLAG) -c $^ -o $@

.PHONY:clean
clean:
	-@rm $(OBJS)
	-@rm *.elf
	-@rm *.hex
	-@rm *.a
